package com.maddox.libnetwork;

import java.util.Map;

import okhttp3.FormBody;

/**
 *  Post请求
 * @param <T>
 */
public class PostRequest<T> extends Request<T,PostRequest> {

    public PostRequest(String url) {
        super(url);
    }

    @Override
    protected okhttp3.Request generateRequest(okhttp3.Request.Builder builder) {
        FormBody.Builder formBuilder = new FormBody.Builder();
        for (Map.Entry<String, Object> entry : params.entrySet()) {
            formBuilder.add(entry.getKey(),String.valueOf(entry.getValue()));
        }

        return builder.post(formBuilder.build()).build();
    }
}
